
/* This do file provides the code to generate Figure A3.2 in Appendix 3. */

global dataDir "~/Dropbox/Party_Interactions_Perceptions/PSRM Submission/Replication Files"
use "$dataDir/replication_data.dta", clear



set more off
foreach i of numlist 1 2{

replace dyad_name`i'="AfD" if dyad_name`i'=="afd"
replace dyad_name`i'="Alt" if dyad_name`i'=="alt"
replace dyad_name`i'="BQ" if dyad_name`i'=="bq"
replace dyad_name`i'="CDU" if dyad_name`i'=="cdu"
replace dyad_name`i'="Cons" if dyad_name`i'=="cons"
replace dyad_name`i'="KF" if dyad_name`i'=="cpp"
replace dyad_name`i'="DF" if dyad_name`i'=="dpp"
replace dyad_name`i'="Enh" if dyad_name`i'=="enh"
replace dyad_name`i'="FDP" if dyad_name`i'=="fdp"
replace dyad_name`i'="Lab" if dyad_name`i'=="lab"
replace dyad_name`i'="Lib" if dyad_name`i'=="lib"
replace dyad_name`i'="LibDem" if dyad_name`i'=="libdem"
replace dyad_name`i'="Linke" if dyad_name`i'=="linke"
replace dyad_name`i'="NDP" if dyad_name`i'=="ndp"
replace dyad_name`i'="NB" if dyad_name`i'=="new"
replace dyad_name`i'="RadVen" if dyad_name`i'=="rad"
replace dyad_name`i'="SDP" if dyad_name`i'=="sdp"
replace dyad_name`i'="SNP" if dyad_name`i'=="snp"
replace dyad_name`i'="SPD" if dyad_name`i'=="spd"
replace dyad_name`i'="SF" if dyad_name`i'=="spp"
replace dyad_name`i'="UKIP" if dyad_name`i'=="ukip"
replace dyad_name`i'="Ven" if dyad_name`i'=="ven"
replace dyad_name`i'="Green" if dyad_name`i'=="green"


}

capture drop dyadname
egen dyadname=concat(dyad_name1 dyad_name2), punct("-")


capture drop countryyear
egen countryyear=concat(country year)



 /* Denmark 2019 */
 
 set more off

local figure=1
levelsof dyadname if countryyear=="Denmark2019" & coop!=., local(levels) 
 foreach l of local levels {
 
sum coop if dyadname=="`l'" & countryyear=="Denmark2019" & coop!=.

local ll2 : di %3.2f r(mean)

 
twoway histogram coop if dyadname=="`l'" & countryyear=="Denmark2019" ///
 & coop!=., ///
 discrete percent xtitle("") ytitle("") color(gray) xline(`ll2') ///
 text(30 `ll2' "`ll2'") title("`l'") graphregion(margin(0 0 0 0)) plotregion(margin(0 0 0 0)) ///
 name(`ctryyear'fig`figure', replace) yscale(r(0 35)) nodraw
 
 local figure=`figure'+1
 
 }
 
 
 set more off
 capture drop partiesname
 gen partiesname=""
 
  capture drop avg
 gen avg=.
 
 local row=1
 levelsof dyadname if countryyear=="Denmark2019", local(levels) 
 foreach l of local levels {
 sum coop if dyadname=="`l'" & countryyear=="Denmark2019" & coop!=.
replace avg=r(mean) in `row'
  replace partiesname="`l'" in `row'
  local row=`row'+1

 }
 capture drop groupid
 egen groupid=group(partiesname)
 

 
graph combine fig41 fig31 fig39 fig42 fig34 fig30 fig26 fig5 fig15 ///
fig7 fig10 fig23 fig33 fig16 fig44 fig43 , ///
 l1(% of Respondents) b1() rows(4) ///
 note("",size(vsmall)) ///
 ycommon scale(1.15) title(Denmark 2019)  
 
  graph export "$dataDir/figA3_2(part 1).pdf", replace

 

 graph combine fig24 fig19 fig6 fig17 fig18 fig20 fig25 fig32 fig21 ///
 fig27 fig8 fig28 fig45 fig14 fig38 fig1, ///
 l1(% of Respondents) b1(Perceived Cooperation Scores) rows(4) ///
 note("Dashed line indicates the average cooperation score",size(vsmall)) ///
 ycommon scale(1.15)   
 
 graph export "$dataDir/figA3_2(part 2).pdf", replace

 
  graph combine fig29 fig35 fig36 fig22 fig9 fig2 fig3 fig37 ///
 fig11 fig12 fig4 fig40 fig13, ///
 l1(% of Respondents) b1(Perceived Cooperation Scores) rows(4) ///
 note("Dashed line indicates the average cooperation score",size(vsmall)) ///
 ycommon scale(1.15) title(Denmark 2019 (cont'd))   

 graph export "$dataDir/figA3_2(part 3).pdf", replace






